package dao.admin.impl;

import dao.BaseDao;
import dao.admin.BooksDao;
import entity.Books;

/**
 * BooksDaoImpl
 *
 * @author 谭文斌
 * @since 2023/9/4
 */
public class BooksDaoImpl extends BaseDao implements BooksDao {
    @Override
    public int upd(Books books) {
        String sql="update books set name=? ,author=? ,library_id=? ,sort_id=? ,position=? ,status=?, description=? where id=?";
        return super.executeUpdate(sql,books.getName(),books.getAuthor(),books.getLibrary_id(),books.getSort_id(),books.getPosition(),books.getStatus(),books.getDescription(),books.getId());
    }

    @Override
    public int add(Books books) {
        String sql = "insert into books(name, author, library_id, sort_id, position, status, description) values(?,?,?,?,?,?,?)";
        return super.executeUpdate(sql,books.getName(),books.getAuthor(),books.getLibrary_id(),books.getSort_id(),books.getPosition(),books.getStatus(),books.getDescription());
    }

    @Override
    public int del(int id) {
        String sql = "delete from books where id=?";
        return super.executeUpdate(sql, id);
    }
}
